package com.toommi.refuse.common.enums;

/**
 * ..
 * 验证码类型枚举
 *
 * @author yangg
 * @since 2019-08-05 12:04
 */
public enum VerifyCodeTypeEnum {
    /**
     * 类型
     */
    WECHAT_USER_REGISTER(1, "微信端用户注册", RedisKeyEnum.WECHAT_USER_REGISTER),

    APP_USER_FINDPASS(2, "APP用户找回密码", RedisKeyEnum.APP_USER_FINDPASS),

    END(-1, "OTHER", RedisKeyEnum.END);

    private int code;

    private String note;

    private RedisKeyEnum keyEnum;

    public int getCode() {
        return code;
    }

    public RedisKeyEnum getKeyEnum() {
        return keyEnum;
    }

    public String getNote() {
        return note;
    }

    VerifyCodeTypeEnum(int code, String note) {
        this.code = code;
        this.note = note;
    }

    public static boolean hasValue(int code) {
        for (VerifyCodeTypeEnum typeEnum : VerifyCodeTypeEnum.values()) {
            if (typeEnum.getCode() == code) {
                return true;
            }
        }
        return false;
    }

    VerifyCodeTypeEnum(int code, String note, RedisKeyEnum keyEnum) {
        this.code = code;
        this.note = note;
        this.keyEnum = keyEnum;
    }

    public static VerifyCodeTypeEnum getTypeEnum(int code) {
        for (VerifyCodeTypeEnum typeEnum : VerifyCodeTypeEnum.values()) {
            if (typeEnum.getCode() == code) {
                return typeEnum;
            }
        }
        return END;
    }


}
